package mybatis;

import java.io.File;  
import java.util.ArrayList;  
import java.util.List;  
  
//import junit.framework.TestCase;  
  

import org.mybatis.generator.api.MyBatisGenerator;  
import org.mybatis.generator.config.Configuration;  
import org.mybatis.generator.config.xml.ConfigurationParser;  
import org.mybatis.generator.internal.DefaultShellCallback;  
  
/** 
 * mybatis反向工具，可以使用此生成所需代码。
 *  
 * @author dongjian 
 * */  
public class MyBatisGeneratorMain {//extends TestCase {
      
    private String confFilePath = "generatorConfig.xml";  
  
    public final void testGenerator() throws Exception {  
          
        List<String> warnings = new ArrayList<String>();  
          
        confFilePath = this.getClass().getResource(confFilePath).getFile();  
          
        File configFile = new File(confFilePath);  
          
        Configuration config = new ConfigurationParser(warnings).parseConfiguration(configFile);  
          
        DefaultShellCallback callback = new DefaultShellCallback(true);  
          
        MyBatisGenerator myBatisGenerator = new MyBatisGenerator(config, callback, warnings);  
          
        myBatisGenerator.generate(null);  
    }  
    
    public static void main(String[] args) throws Exception {
    	MyBatisGeneratorMain mbgt = new MyBatisGeneratorMain();
    	mbgt.testGenerator();
	}
      
}  
